﻿Imports Global_Visas_Business_Layer
Partial Public Class frmCaseHold

    Private Sub btnOK_Click(ByVal sender As System.Object, ByVal e As System.Windows.RoutedEventArgs) Handles btnOK.Click
        Dim cmn As New CommonFuncs
        Try

        
            If txtDate.Text.Trim = String.Empty Or txtReason.Text.Trim = String.Empty Then
                CommonFuncs.DisplayMessage("Please fill in the mandatory fields(Reason and Date until when you would like to keep the case on hold", CommonDialog.CustomDialogIcons.Information, "Hold")
                Exit Sub

                'ExpiryDate = InputBox("Please enter the new expiry date" & vbCrLf & "(For EC cases please estimate)", "Expiry date", FormatDate(myCaseInfo.ExpiryDate))
            Else
                'validate date and store for later
                If Not IsNumeric(txtDate.Text) Then
                    CommonFuncs.DisplayMessage("Please enter a valid number of days less than or equal to 60", CommonDialog.CustomDialogIcons.Information, "Valid Number")
                    GlobalCRM.HoldReason = String.Empty
                    Exit Sub
                Else
                    If CInt(txtDate.Text) > 60 Then
                        CommonFuncs.DisplayMessage("Please enter a number less than and equal to 60", CommonDialog.CustomDialogIcons.Information, "Number of days")
                        GlobalCRM.HoldReason = String.Empty
                        Exit Sub
                    Else
                        GlobalCRM.HoldDate = cmn.FormatDate(DateTime.Now.AddDays(txtDate.Text))
                    End If
                End If


                GlobalCRM.HoldReason = txtReason.Text.ToString
                Me.Close()
            End If
        Catch ex As Exception
        Finally
            cmn = Nothing
        End Try
    End Sub

    Private Sub btnCancel_Click(ByVal sender As System.Object, ByVal e As System.Windows.RoutedEventArgs) Handles btnCancel.Click
        Try
            GlobalCRM.HoldReason = String.Empty
            GlobalCRM.HoldDate = String.Empty
            Me.Close()
        Catch ex As Exception

        End Try
    End Sub

    Private Sub frmCaseHold_Loaded(ByVal sender As Object, ByVal e As System.Windows.RoutedEventArgs) Handles Me.Loaded
        GeneralTasks.ChangeTheme(Me)
        GeneralTasks.EnumerateandFill(Me.LogicalChildren)
    End Sub
End Class
